/**
 * vertexarrayobject.h
 * 
 * @author Zsolt Horváth 
 * @date   3. 4. 2011
 * 
 */

#ifndef VERTEX_ARRAY_OBJECT_H
#define VERTEX_ARRAY_OBJECT_H

#include <GL/glew.h>
#include <GL/glu.h>

/**
 * OpenGL Vertex Array Object
 */
class VertexArrayObject {
    
    public:
        
        /**
         * Constructor
         */
        VertexArrayObject ();
        
        /**
         * Destructor
         */
        ~VertexArrayObject ();

        /**
         * Bind vertex array object 
         */
        void bind ();
        
        /**
         * Draw elements of binded buffers
         */
        void drawElements();
        
        /**
         * Set render primitives
         * @param GLenum mode - specifies what kind of primitives to render
         * @param GLsizei count - specifies the number of elements to be rendered
         * @param GLenum type - specifies the type of the values in indices
         * @param const GLvoid * indices - specifies a pointer to the location
         *                                 where the indices are stored
         */
        void setDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
        
        /**
         * Set clear mask for glClear
         */
        void setClearMask(GLbitfield mask);
        
        /**
         * Call glClear to clear buffers to preset values
         */
        void clearBuffers ();
        
    protected:
        
        /**
         * ID of vertex array object
         */
        GLuint id;
        
        GLenum drawMode;
        GLsizei drawCount;
        GLenum drawType;
        const GLvoid * drawIndices;
        
        GLbitfield clearMask;
        
        /**
         * Generate new vertex array object
         */
        void generate ();
        
};

#endif /* VERTEX_ARRAY_OBJECT_H */